import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path' //通过path组件引入路径解析函数resolve

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],

  resolve: {
    //使用“@”表示项目的src目录
    alias: [
      {
        find: '@',
        replacement: resolve(__dirname, './src'),
      }
    ]
  },

  server:{
    host:true,
    port:8888,

    //服务代理配置
    proxy:{
      '/api': {
        target: 'http://localhost:9999',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    }
  }
})